package com.itboye.mengwu.app.adapter;

import java.util.ArrayList;
import java.util.List;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.itboye.mengwu.R;
import com.itboye.mengwu.data.model.GridViewBean;


public class HomePageSecondAdapter extends BaseAdapter{
	private Context context;
		
	
	private ArrayList<GridViewBean> list;
	public  HomePageSecondAdapter(ArrayList<GridViewBean> list,Context context){
		this.list=list;
		this.context=context;
		
	}
	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return list==null?0:list.size();
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return list==null?new ArrayList<GridViewBean>():list.get(position);
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		MyHolder holder = null;
		if(convertView==null){
			holder=new MyHolder();
			LayoutInflater layoutInflater = LayoutInflater.from(context);
			convertView = layoutInflater.inflate(R.layout.item_home_page_second, null);
//			holder.img= (ImageView) convertView.findViewById(R.id.img_view);
//			holder.item_textview=(TextView) convertView.findViewById(R.id.item_textview);
			convertView.setTag(holder);
		}else{
			holder=(MyHolder) convertView.getTag();
		}
//		holder.item_textview.setText(list.get(position).getCountext());
//		holder.img.setImageResource(list.get(position).getUrl());
//		convertView.findViewById(R.id.itemlayout).setBackgroundColor(list.get(position).getUrl());
//		tvCode.setText(city.getCityCode());
		return convertView;
	}
	
	public  class MyHolder{
		private TextView item_textview;
		private ImageView img;
	}
	
}

